home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 003a / asmwiz16.zip / EXAMPLE.ASM < prev    next >
Assembly Source File  |  1993-05-23  |  16KB  |  307 lines

  1. comment $
  2.  
  3.    +----------------------------------------------------------------------+
  4.    |                                                                      |
  5.    |        AsmWiz  Copyright (c) 1990-1993  Thomas G. Hanlin III         |
  6.    |                                                                      |
  7.    |                          AsmWiz Demo Program                         |
  8.    |                                                                      |
  9.    |                        assembled with MASM 6.0                       |
  10.    |                                                                      |
  11.    +----------------------------------------------------------------------+
  12.  
  13.    The code here has been designed to be easily understandable and is not as
  14.    efficient as the coding used in the actual library.
  15. $
  16.  
  17.  
  18. ; the use of a dummy stack segment here eliminates the meaningless error
  19. ; message from LINK about there being no stack defined.
  20.  
  21. Sseg          segment byte stack 'prog'     ; dummy stack segment
  22. Sseg          ends
  23.  
  24. Cseg          segment byte public 'prog'
  25.  
  26.               assume cs:Cseg, ds:Cseg, ss:Sseg
  27.  
  28.               org            100h
  29.  
  30.  
  31.  
  32. extrn  BKO_GETKEY:near, MD_DONE:near, MD_DELAY:near, MD_INIT:near
  33. extrn  MV_INIT:near, MV_LOCATE:near, MV_MODE:near, MV_GETMODE:near
  34. extrn  MV_POPUP:near, MV_STROUT:near, MV_HIDECURSOR:near
  35. extrn  MV_SHOWCURSOR:near, MV_STROUT:near, MV_INSLINE:near, MV_DELLINE:near
  36. extrn  MV_INSCHR:near, MV_DELCHR:near, MV_COLOR:near, MV_CLS:near
  37. extrn  MV_FIXCOLOR:near, MV_FRAME:near, MI_GETSCREEN:near, MI_PARSE:near
  38. extrn  S0_LENGTH:near, S0_UPCASES:near, ME_BLOAD:near
  39.  
  40.  
  41.  
  42. MAIN          proc           far       ; AsmWiz example program
  43.               call           Initialize     ; initialize screen and colors
  44.               call           ShowWelcome    ; display welcome message
  45.               call           SlideWelcome   ; slide welcome message left
  46.               call           ShowWindow     ; display pop-up window w/ text
  47.               call           ShowCopyright  ; display copyright message
  48.               call           WaitOnKey      ; display "press any" and wait
  49.               call           Picture        ; display picture (if CGA/EGA/VGA)
  50.               call           Terminate      ; restore original screen mode, etc
  51.               mov            ax,4C00h       ;
  52.               int            21h            ; exit program
  53. MAIN          endp                     ; AsmWiz example program
  54.  
  55.  
  56.  
  57. Initialize    proc           near      ; initialize the screen
  58.               call           MV_GETMODE     ; get current screen mode
  59.               mov            OldMode,al     ; save it
  60.               call           MV_INIT        ; initialize display routines
  61.               mov            al,3           ; mode 3: 80x25 color text
  62.               call           MV_MODE        ; set display mode
  63.               call           MV_HIDECURSOR  ; turn off the cursor
  64.               mov            si,0080h       ; pointer to the command line
  65.               lea            di,FileBuf     ; pointer to filename buffer
  66.               lea            bx,OptBuf      ; pointer to option buffer
  67.               mov            al,"/"         ; use normal DOS switch character
  68.               call           MI_PARSE       ; parse the command line
  69.               or             ah,ah          ; is there an option?
  70.               jz             CheckCRT       ;   no, go check the CRT type
  71.               mov            si,bx          ; pointer to first option
  72.               mov            di,bx          ;
  73.               call           S0_UPCASES     ; convert it to uppercase
  74.               cmp byte ptr   [bx],"B"       ; is it /B for monochrome mode?
  75.               jne            CheckCRT       ;   no, check CRT type
  76.               mov            al,1           ; set to mono
  77.               jmp            SetCRT         ;   go set type
  78. CheckCRT:     call           MI_GETSCREEN   ; see what the screen type is
  79. SetCRT:       call           MV_FIXCOLOR    ; set the color handler to suit
  80.               mov            al,1Fh         ; bright white on blue
  81.               call           MV_COLOR       ; set text color
  82.               call           MV_CLS         ; clear screen to new color
  83.               call           MD_INIT        ; initialize hi-res timer system
  84.               ret                           ;
  85. Initialize    endp                     ; initialize the screen
  86.  
  87.  
  88.  
  89. ShowWelcome   proc           near      ; display welcome message
  90.               mov            dx,0125h       ; row 1, column 37
  91.               call           MV_LOCATE      ; set cursor location
  92.               lea            dx,WelcomeMsg  ; ptr to "Welcome"
  93.               call           MV_STROUT      ; display it
  94.               mov            cx,8           ;
  95. Welcome1:     call           MV_INSLINE     ; scroll it down
  96.               push           cx             ;
  97.               mov            cx,4           ;
  98.               call           MD_DELAY       ; delay 4/100ths of a second
  99.               pop            cx             ;
  100.               loop           Welcome1       ; ...nine times
  101.               mov            dx,0B25h       ; row 11, column 37
  102.               call           MV_LOCATE      ; set cursor location
  103.               lea            dx,ToTheMsg    ; ptr to "to the"
  104.               call           MV_STROUT      ; display it
  105.               mov            dx,0D01h       ; row 13, column 1
  106.               call           MV_LOCATE      ; set cursor location
  107.               lea            dx,AsmMsg      ; ptr to "Asm" <cr>
  108.               call           MV_STROUT      ; display it
  109.               mov            cx,37          ;
  110. Welcome2:     call           MV_INSCHR      ; scroll it right
  111.               push           cx             ;
  112.               mov            cx,2           ;
  113.               call           MD_DELAY       ; delay 2/100ths of a second
  114.               pop            cx             ;
  115.               loop           Welcome2       ; ...37 times
  116.               mov            dx,0D4Dh       ; row 13, column 73
  117.               call           MV_LOCATE      ;
  118.               lea            dx,WizMsg      ; ptr to "Wiz"
  119.               call           MV_STROUT      ; display it
  120.               mov            dx,0D29h       ; row 13, column 41
  121.               call           MV_LOCATE      ; set cursor location
  122.               mov            cx,36          ;
  123. Welcome3:     call           MV_DELCHR      ; scroll it left
  124.               push           cx             ;
  125.               mov            cx,2           ;
  126.               call           MD_DELAY       ; delay 2/100ths of a second
  127.               pop            cx             ;
  128.               loop           Welcome3       ; ...36 times
  129.               mov            dx,1925h       ; row 25, column 37
  130.               call           MV_LOCATE      ; set cursor location
  131.               lea            dx,LibraryMsg  ; ptr to "Library"
  132.               call           MV_STROUT      ; display it
  133.               mov            dx,0E01h       ; row 14, column 1
  134.               call           MV_LOCATE      ; set cursor location
  135.               mov            cx,10          ;
  136. Welcome4:     call           MV_DELLINE     ; scroll it up
  137.               push           cx             ;
  138.               mov            cx,4           ;
  139.               call           MD_DELAY       ; delay 4/100ths of a second
  140.               pop            cx             ;
  141.               loop           Welcome4       ; ...10 times
  142.               mov            cx,200         ; delay 200/100ths of a second
  143.               call           MD_DELAY       ;
  144.               ret                           ;
  145. ShowWelcome   endp                     ; display welcome message
  146.  
  147.  
  148.  
  149. SlideWelcome  proc           near      ; slide welcome message left
  150.               mov            dx,0901h       ; row 9, column 1
  151.               mov            ax,4           ;
  152. ScrollAll:    mov            cx,20          ; columns to scroll
  153. LineLeft:     call           MV_LOCATE      ; set cursor position
  154.               call           MV_DELCHR      ; scroll it left
  155.               loop           LineLeft       ;   go for all columns
  156.               add            dh,2           ; move to next line
  157.               dec            ax             ; done yet?
  158.               jnz            ScrollAll      ;   no, go for next row
  159.               mov            al,15h         ; magenta on white
  160.               call           MV_COLOR       ; set text color
  161.               mov            cx,070Eh       ; upper left row, col
  162.               mov            dx,111Ah       ; lower right row, col
  163.               mov            si,-9          ; solid block frame
  164.               mov            ax,4           ; frame loop count
  165. WildFrame:    call           MV_FRAME       ; display frame
  166.               sub            cx,0101h       ; move upper left corner out one
  167.               add            dx,0101h       ; move lower right corner out one
  168.               inc            si             ; set to next lighter frame type
  169.               dec            ax             ; are we still drawing frames?
  170.               jnz            WildFrame      ;   yep, go draw that funky thang
  171.               ret                           ;
  172. SlideWelcome  endp                     ; slide welcome message left
  173.  
  174.  
  175.  
  176. ShowCopyright proc           near      ; display copyright message
  177.               mov            dx,010Fh       ; row 1, column 15
  178.               call           MV_LOCATE      ; set cursor position
  179.               mov            al,1Bh         ; cyan on blue
  180.               call           MV_COLOR       ; set text color
  181.               lea            dx,CopyrMsg    ; copyright text
  182.               call           MV_STROUT      ; display it
  183.               ret                           ;
  184. ShowCopyright endp                     ; display copyright message
  185.  
  186.  
  187.  
  188. ShowWindow    proc           near      ; display pop-up window w/ text
  189.               lea            dx,ScrWindow   ;
  190.               call           MV_POPUP       ; pop up intro window
  191.               lea            si,WindowText  ; pointer to window text
  192.               mov            dx,word ptr ScrWindow
  193.               xchg           dl,dh          ;
  194.               add            dx,0102h       ; starting text position
  195. ShowText:     call           MV_LOCATE      ; set cursor position
  196.               call           S0_LENGTH      ; determine length of text
  197.               jcxz           ShoWindowXit   ;   if zero, we're done-- go exit
  198.               mov            al,[si]        ; get text color
  199.               call           MV_COLOR       ; set it
  200.               inc            si             ; skip over color to actual text
  201.               xchg           dx,si          ;
  202.               call           MV_STROUT      ; display the text
  203.               xchg           dx,si          ;
  204.               add            si,cx          ; move to next text line
  205.               inc            dh             ; move to next screen line
  206.               jmp            ShowText       ;   go for all text
  207. ShoWindowXit: ret                           ;
  208. ShowWindow    endp                     ; display pop-up window w/ text
  209.  
  210.  
  211.  
  212. WaitOnKey     proc           near      ; display "press any key", wait for it
  213.               mov            dx,191Bh       ; row 25, column 26
  214.               call           MV_LOCATE      ; set cursor location
  215.               mov            al,74h         ; red on white
  216.               call           MV_COLOR       ;
  217.               lea            dx,PressAnyMsg ; ptr to "Press any key..."
  218.               call           MV_STROUT      ; display it
  219.               mov            al,07h         ; normal video
  220.               call           MV_COLOR       ;
  221.               mov            al,1           ; wait for key
  222.               call           BKO_GETKEY     ; get a key
  223.               ret                           ;
  224. WaitOnKey     endp                     ; display "press any key", wait for it
  225.  
  226.  
  227.  
  228. Picture       proc           near      ; display picture (if CGA/EGA/VGA)
  229.               call           MI_GETSCREEN   ; get active display type
  230.               or             al,al          ; color display?
  231.               jnz            PictureXit     ;   no, go exit
  232.               cmp            ah,3           ; CGA?
  233.               je             CGApic         ;   yep, go do CGA picture
  234.               cmp            ah,4           ; EGA?
  235.               je             EGApic         ;   yep, go do EGA picture
  236.               cmp            ah,6           ; VGA?
  237.               jne            PictureXit     ;   no, go exit
  238. EGApic:       mov            al,16          ; EGA/VGA 640x350 graphics mode
  239.               call           MV_MODE        ; set the screen mode
  240.               lea            dx,EGAfile     ; EGA file name
  241.               call           ME_BLOAD       ; load it onto the screen
  242.               jmp            WaitForKey     ;   go wait for a keypress
  243. CGApic:       mov            al,6           ; CGA 640x200 graphics mode
  244.               call           MV_MODE        ; set the screen mode
  245.               lea            dx,CGAfile     ; CGA file name
  246.               call           ME_BLOAD       ; load it onto the screen
  247. WaitForKey:   mov            al,1           ; wait for key
  248.               call           BKO_GETKEY     ; get a key
  249. PictureXit:   ret                           ;
  250. Picture       endp                     ; display picture (if CGA/EGA/VGA)
  251.  
  252.  
  253.  
  254. Terminate     proc           near      ; restore original screen mode, etc
  255.               call           MD_DONE        ; shut down hi-res timer system
  256.               mov            al,OldMode     ; get old screen mode
  257.               call           MV_MODE        ; set video mode
  258.               call           MV_SHOWCURSOR  ; restore the cursor
  259.               ret                           ;
  260. Terminate     endp                     ; restore original screen mode, etc
  261.  
  262.  
  263.  
  264. WelcomeMsg    db "Welcome",0
  265. ToTheMsg      db "to the",0
  266. AsmMsg        db "Asm",13,0
  267. WizMsg        db "Wiz",0
  268. LibraryMsg    db "Library",0
  269. CopyrMsg      db "AsmWiz  Copyright 1990-1993  Thomas G. Hanlin III",0
  270. PressAnyMsg   db "Press any key to continue",0
  271.  
  272. ScrWindow     db 3,40,23,79        ; window coordinates
  273.               db 1,4Eh             ; frame type and color
  274.               dw offset ScrTitle   ; pointer to title
  275. ScrTitle      db "The Assembly Wizard's Library",0   ; window title
  276.  
  277. WindowText    db 4Ah,"Let's face it, asm programming can  ",0
  278.               db 4Ah,"be slow.  By the time you finish all",0
  279.               db 4Ah,"the low-level stuff, you forget what",0
  280.               db 4Ah,"you wanted to do in the first place!",0
  281.               db 4Ah,"AsmWiz takes care of all the little ",0
  282.               db 4Ah,"tedious details for you, so you can ",0
  283.               db 4Ah,"concentrate on the real work.       ",0
  284.               db 4Ah,0
  285.               db 70h,"Extensive text and graphics support ",0
  286.               db 30h,"Base conversions and 32-bit math    ",0
  287.               db 70h,"Delay and countdown services        ",0
  288.               db 30h,"Random numbers, checksums, CRCs     ",0
  289.               db 70h,"Parse input or the command line     ",0
  290.               db 30h,"Scan DOS environment variables      ",0
  291.               db 70h,"Intercept Break and Control-C       ",0
  292.               db 30h,"String functions, sound effects     ",0
  293.               db 70h,"Mouse and keyboard management       ",0
  294.               db 30h,"File handling with buffers, sharing ",0
  295.               db 70h,"International time and date support ",0,0
  296.  
  297. FileBuf   db 80 dup(?)
  298. OptBuf    db 80 dup(?)
  299.  
  300. OldMode   db 3
  301.  
  302. CGAfile   db "EXAMPLE.CGA",0
  303. EGAfile   db "EXAMPLE.EGA",0
  304.  
  305. Cseg          ends
  306.               end            MAIN
  307.